|
![](/i/fill.gif) |
Hello!
(Don't know, if this is already reported. If there were search engine
for news server... [hint, hint])
I found a memory leak in pvbmp.c. It seems to be present in most recent
version of official POV-Ray (v. 3.1g) and if v. 3.5 is based on same
Windows code, then it will be relevant to new version as well (or may-be
it is already corrected?)
Memory leak is in pvbmp.c file, line 744, where buffer is allocated for
filling bitmap file with line info, containing in the beginning BMP
magic bytes, but this buffer is never released.
====================8<===================
magic = POV_MALLOC(((*width*24+31)/32)*4, "BMP magic");
<---allocation
memset(magic, 0, ((*width*24+31)/32)*4);
magic[0] = MAGIC1;
magic[1] = MAGIC2;
magic[2] = MAGIC3;
for (i=0; i<*height; i++)
fwrite(magic, ((*width*24+31)/32)*4, 1, f);
<---no freeing!
break;
====================8<===================
Additionally, this code could be more effective, if instead of
calculating same expression for buffer size 3 times it is calculated
once and held in temporary variable. Moreover, for() loop is
unneccessary, instead fwrite could be used with count parameter (2nd
parameter) equal to *height.
Post a reply to this message
|
![](/i/fill.gif) |